let moment = require("moment");

/**
 * 计算两个日期之间的时间差
 * @param {string} startDateStr - 开始日期
 * @param {string} endDateStr - 结束日期
 * @param {moment.unitOfTime.Diff} unit - 时间单位（days, seconds, minutes, hours, weeks, months, years）
 * @returns {number} - 两日期相差的时间数
 */
const getTimeDiffBetweenDates = (startDateStr , endDateStr , unit)  => {
	const startDate = moment(startDateStr);
	const endDate = moment(endDateStr);
	const diff = endDate.diff(startDate, unit);
	return diff;
};


module.exports={
    getTimeDiffBetweenDates
}
